﻿using EfSandbox.Entities.Final.Common;
using EfSandbox.Entities.Final.Common.Mappings;
using EfSandbox.Entities.Final.Eod;
using EfSandbox.Entities.Final.Eod.Mappings;
using EfSandbox.Entities.Final.Eod.Raw;
using EfSandbox.Entities.Final.Eod.Raw.Mappings;
using System.Data.Entity;

namespace EfSandbox.Context {
    public class SandboxContext : DbContext {
        public SandboxContext() : base("name=EfSandbox") {
            
        }

        // Final Schema
        public virtual DbSet<Exchange> Exchanges { set; get; }
        public virtual DbSet<TimeZone> TimeZones { set; get; }
        public virtual DbSet<Currency> Currencies { set; get; }
        public virtual DbSet<Country> Countries { set; get; }
        public virtual DbSet<Symbol> Symbols { set; get; }
        public virtual DbSet<Quote> Quotes { set; get; }
        public virtual DbSet<Category> Categories { get; set; }
        public virtual DbSet<Frequency> Frequencies { set; get; }

        // Raw Schema
        public virtual DbSet<RawSymbol> RawSymbols { set; get; }
        public virtual DbSet<RawQuote> RawQuotes { set; get; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder) {
            // Final Schema
            modelBuilder.Configurations.Add(new ExchangeMap());
            modelBuilder.Configurations.Add(new TimeZoneMap());
            modelBuilder.Configurations.Add(new CurrencyMap());
            modelBuilder.Configurations.Add(new CountryMap());
            modelBuilder.Configurations.Add(new SymbolMap());
            modelBuilder.Configurations.Add(new QuoteMap());
            modelBuilder.Configurations.Add(new CategoryMap());
            modelBuilder.Configurations.Add(new FrequencyMap());
            modelBuilder.Configurations.Add(new OptionTypeMap());

            // Raw Schema
            modelBuilder.Configurations.Add(new RawSymbolMap());
            modelBuilder.Configurations.Add(new RawQuoteMap());
        }
    }
}
